<?php

	class CalendarController extends Zend_Controller_Action {
		
		public function init() {
			
			$this->view->headLink()
					->appendStylesheet($this->_request->getBaseUrl().'/styles/commun.css')
					->appendStylesheet($this->_request->getBaseUrl().'/styles/template.css')
					->appendStylesheet($this->_request->getBaseUrl().'/styles/calendar.css');
			
			$this->view->action = $this->_request->getActionName();
			$this->view->controller = $this->_request->getControllerName();
		}
		
		public function indexAction() {
			
			$this->view->headTitle('Hybrid Legacy - Calendrier');
			
			$aM = new Model_Agenda();
			$filter = array('visible' => 1);
			$order = 'start ASC';
			$events_temp = $aM->get($filter, $order);
			
			// sort by month
			$sorted_events = array();
			foreach($events_temp as $e) {
				$date = new Zend_Date($e['start']);
				$events[$date->get(Zend_Date::MONTH).'/'.$date->get(Zend_Date::MONTH).'/'.$date->get(Zend_Date::YEAR)][] = $e;
			}
			
			// generate all month
			$month = Model_Tools::getMonths();
			
			$this->view->events = $events;
		}
		
	}
	
?>
